package com.ruoyi.http.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.data.SysParamKey;
import com.ruoyi.data.domain.ParameterSingleT;
import com.ruoyi.data.service.IParameterSingleService;
import com.ruoyi.http.domain.WeChat02100T;
import com.ruoyi.http.service.IWeChatTService;

import com.ruoyi.util.FileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/http/weChat02100")
public class WeChat02100 extends BaseController {

    @Autowired
    private IWeChatTService weChatTService;
    @Autowired
    private IParameterSingleService parameterSingleService;
    @PostMapping("/weChat")
    public AjaxResult http(WeChat02100T weChat02100T) {
        WeChat02100T weChat = new WeChat02100T();
        ParameterSingleT vo = new ParameterSingleT();
        String date1 = "申请书照片_"+System.currentTimeMillis();
        String date2 = "现场照片1_"+System.currentTimeMillis();
        String date3 = "现场照片2_"+System.currentTimeMillis();
        String date4 = "现场照片3_"+System.currentTimeMillis();
        vo.setParamCode(SysParamKey.CARDA_PPROVE.getKey());
        vo = parameterSingleService.getSysParams(vo);
        FileUtil.base64ToJpg(vo.getParamVal(),weChat02100T.getRequestphoto().split(",")[1],date1,"jpg");
        FileUtil.base64ToJpg(vo.getParamVal(),weChat02100T.getSitephoto1().split(",")[1],date3,"jpg");
        FileUtil.base64ToJpg(vo.getParamVal(),weChat02100T.getSitephoto2().split(",")[1],date3,"jpg");
        FileUtil.base64ToJpg(vo.getParamVal(),weChat02100T.getSitephoto3().split(",")[1],date3,"jpg");
        weChat02100T.setRequestphoto(weChat02100T.getRequestphoto().split(",")[1]);
        weChat02100T.setSitephoto1(weChat02100T.getSitephoto1().split(",")[1]);
        weChat02100T.setSitephoto2(weChat02100T.getSitephoto2().split(",")[1]);
        weChat02100T.setSitephoto3(weChat02100T.getSitephoto3().split(",")[1]);
        weChat02100T.setRequestphotoname("申请书照片");
        weChat02100T.setSitephotoname1("现场照片1");
        weChat02100T.setSitephotoname2("现场照片2");
        weChat02100T.setSitephotoname3("现场照片3");
        weChat02100T.setRequestphotohttp(date1);
        weChat02100T.setSitephotohttp1(date2);
        weChat02100T.setSitephotohttp2(date3);
        weChat02100T.setSitephotohttp3(date4);
        weChatTService.insertRepairApply(weChat02100T);
        return AjaxResult.success(weChat);
    }
}